#ifndef __COMMUNICATION_H__
#define __COMMUNICATION_H__

#include "main.h"

#include "string.h"

#include "my_lib/my_log.h"
#include "my_lib/cmd_analyse.h"

#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"


//格式 帧头1+帧头2+数据字节长度+信息id码+字节1+字节2...+crc校验码高8位+校验码低八位

#define FRAME_HEAD1       0xA5
#define FRAME_HEAD2       0x5A
#define INFOR_MAX_LENGHT  10


typedef enum
{
    POINT_FOLLOW_ID = 0,
    FOLLOW_STOP,
    FOLLOW_READY,
}infor_id_t;

typedef struct 
{
    infor_id_t id;
    uint16_t infor_len;
    uint8_t infor_buf[INFOR_MAX_LENGHT];
    uint16_t crc;
}infor_t;


extern infor_t com_infor;
extern SemaphoreHandle_t com_receive_sem;   //接收成功信号量

void CommunicationReceive(uint8_t info_byte);
void CommunicationTrans(infor_id_t id, uint8_t* pData, uint16_t len);
void TransBytes(uint8_t* pData, uint16_t len);
void ResetInfo(void);

void CommunicationInit(void);


#endif

